package com.dhcc.DRGsHosp.facade.impl;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import javax.inject.Inject;
import javax.inject.Named;

import org.openkoala.koala.commons.InvokeResult;
import org.openkoala.security.shiro.CurrentUser;
import org.springframework.beans.factory.annotation.Autowired;

import com.dhcc.DRGsHosp.application.DepGroupApplication;
import com.dhcc.DRGsHosp.application.DepartmentApplication;
import com.dhcc.DRGsHosp.application.ForeCastApplication;
import com.dhcc.DRGsHosp.application.QuotaAdjustApplication;
import com.dhcc.DRGsHosp.application.QuotaExpectedApplication;
import com.dhcc.DRGsHosp.core.domain.DepGroup;
import com.dhcc.DRGsHosp.core.domain.Department;
import com.dhcc.DRGsHosp.core.domain.ForeCast;
import com.dhcc.DRGsHosp.core.domain.ForeCastParam;
import com.dhcc.DRGsHosp.core.domain.QuotaAdjust;
import com.dhcc.DRGsHosp.core.domain.QuotaExpected;
import com.dhcc.DRGsHosp.facade.DrgsIndexCalFacade;
import com.dhcc.DRGsHosp.facade.ForeCastFacade;
import com.dhcc.DRGsHosp.facade.dto.IndexCalDTO;
import com.dhcc.DRGsHosp.infra.util.Arith;
import com.dhcc.DRGsHosp.infra.util.DrgsIndex;
import com.dhcc.DRGsHosp.infra.util.GlobalData;
import com.dhcc.DRGsHosp.infra.util.MapComparatorImpl;

/**
 * @title :ForeCast.java
 * @description :
 * @author :lileizheng
 * @date :2015年6月8日
 * @version :1.0
 * @copyright :DHCC 2013-2014
 */
@Named("drgsHospFacadeImpl20")
public class ForeCastFacadeImpl implements ForeCastFacade {

	@Inject
	private ForeCastApplication foreCastApplication;

	@Inject
	private QuotaAdjustApplication quotaAdjustApplication;

	@Inject
	private DepGroupApplication depGroupApplication;

	@Inject
	private DrgsIndexCalFacade drgsIndexCalFacade;
    
	@Autowired
	private QuotaExpectedApplication quotaExpectApplication;
	
	@Autowired 
	private DepartmentApplication departmentApplication;

	private Map<String, Object> drgsMap = new ConcurrentHashMap<>();// 存储全部病种预测信息

	private Map<String,Map<String, Object>> drgsNanMap = new HashMap<>();// 存储病种计算标杆信息
	
	// 全院整合
	private double hcTotalFundTT = 0;// 医保总基金
	private double totalxTT = 0;// 科室总床日数
	private double totalCaseCntTT = 0;// 总人数
	private double hcCaseCntTT = 0;// 医保总人数
	private double totalFeeTT = 0;// 预计总费用
	private double hcTotalFeeTT = 0;// 预计医保费用
	private double drugFeeTT = 0;
	private double hcDrugFeeTT = 0;
	private double timeEffTT = 0;
	private double feeEffTT = 0;
	private double drugMateFeeTT = 0;//预计次均药耗费
	private double hcDrugMateFeeTT = 0;//预计医保次均药耗费

//	private int oneSize = 0;// 进度计数器

	static Calendar a = Calendar.getInstance();
	static String year = String.valueOf(a.get(Calendar.YEAR));// 得到年
	static String dateFrom="";
	static String dateTo="";
	
	/**
	 * 
	 *  @Description：医保测算（T：科室，TT:科室组：DT:全院）
	 *  @Author LiuHongJun  
	 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#quotasComputer(com.dhcc.DRGsHosp.facade.dto.IndexCalDTO)
	 */
	@Override
	public InvokeResult quotasComputer(String adjustParameter, String dateFrom, String dateTo, String forecastYear,String hospCode, String monitorType) {
		List<ForeCastParam> foreCastList = new LinkedList<ForeCastParam>();
		// 获取病种计算标杆
		String asId=drgsIndexCalFacade.getStdID(DrgsIndex.formateDateFrom(dateFrom), DrgsIndex.formateDateTo(dateTo));
//		//获取去年度病组的平均住院日和次均费用
//		List<Map<String, Object>> listDrg=foreCastApplication.getDrgStdYear(asId);
//		if(!listDrg.isEmpty()) {
//			for(Map<String, Object> map:listDrg) {
//				Map<String, Object> drgmap=new HashMap<>();
//				drgmap.put("AvgDays", map.get("AVGDAYS"));
//				drgmap.put("AvgFee", map.get("AVGFEE"));
//				drgsNanMap.put(map.get("DRGCODE")==null?null:map.get("DRGCODE").toString(),drgmap);
//			}
//		}
		// 获取科室的入组病例数
//		oneSize = 0;
		GlobalData.cookie.put("states", "start");
		String[] depGroupList = adjustParameter.split(",");
		// 以下为科室组添加更新调整参数
		for (String depGroupParam:depGroupList) {
			QuotaAdjust quotaAdjust = new QuotaAdjust();
			ForeCastParam foreCastParam = new ForeCastParam();
			quotaAdjust.setPlanYear(forecastYear);
			String[] param = depGroupParam.split("\\|");
			String depGroupCode = param[0];
			if("depGroup".equals(monitorType)){
				quotaAdjust.setParDepGroupCode(depGroupCode);
			}else if("dep".equals(monitorType)){
				quotaAdjust.setDepCode(depGroupCode);
			}
			for (String quotas : param[1].split("-")) {
				String[] quotaValue = quotas.split(":");
				quotaAdjust.setQuotaCode(quotaValue[0]);
				quotaAdjust.setHighValue(quotaValue[2] != null ? Double.parseDouble(quotaValue[2]) : 0);
				quotaAdjust.setLowValue(quotaValue[1] != null ? Double.parseDouble(quotaValue[1]) : 0);
				quotaAdjust.setRoleName(DrgsIndex.getRoleCode());
				;
				String id = depGroupCode + "_" + forecastYear + "_" + quotaValue[0] +"_"+ DrgsIndex.getRoleCode();
				quotaAdjust.setId(id);
				// 更新科室组的调整参数
				quotaAdjustApplication.updateQuotaAdjust(quotaAdjust);
				setAdjuestParamToCastParam(foreCastParam, quotaAdjust);
			}
			foreCastParam.setDepGroupCode(depGroupCode);
			foreCastList.add(foreCastParam);
		}
		hcTotalFundTT = 0;// 医保总基金
		totalxTT = 0;// 科室总床日数
		totalCaseCntTT = 0;// 总人数
		hcCaseCntTT = 0;// 医保总人数
		totalFeeTT = 0;// 预计总费用
		hcTotalFeeTT = 0;// 预计医保费用
		drugFeeTT = 0;
		hcDrugFeeTT = 0;
		timeEffTT = 0;
		feeEffTT = 0;
		drugMateFeeTT = 0;
		hcDrugMateFeeTT = 0;
//		oneSize = 0;// 进度计数器
		List<Map<String, Object>> resultList = new LinkedList<>();
		List<Map<String, Object>> resultListDepGroup = new LinkedList<>();
		List<Map<String, Object>> resultListDep = new LinkedList<>();
//		for (ForeCastParam foreCastParam : foreCastList) {// 循环科室组
//			
//			IndexCalDTO dto = new IndexCalDTO();
//			// 科室组累计
//			double hcTotalFundDT = 0;// 医保总基金
//			double totalxDT = 0;// 科室总床日数
//			double totalCaseCntDT = 0;// 总人数
//			double hcCaseCntDT = 0;// 医保总人数
//			double totalFeeDT = 0;// 预计总费用
//			double hcTotalFeeDT = 0;// 预计医保费用
//			double drugFeeDT = 0;//预计药品费用
//			double hcDrugFeeDT = 0;//预计医保药品费用
//			double timeEffDT = 0;//预计时间消耗指数
//			double feeEffDT = 0;//预计费用消耗指数
//			double drugMateFeeDT = 0;//预计药耗费
//			double hcDrugMateFeeDT = 0;//预计医保药耗费
//			List<Map<String, Object>> resultListDeps = new LinkedList<>();
//			String depGroupCode = foreCastParam.getDepGroupCode();
//			dto.setPardepgroupCode(depGroupCode);
//			dto.setMonitorType("dep");
//			dto.setQuotaCode("TotalCaseCnt");
//			dto.setHospCode(hospCode);
//			dto.setDateFrom(dateFrom);
//			dto.setDateTo(dateTo);
//			// 获取该科室组下科室
//			List<Map<String, Object>> depList = foreCastApplication.getDepartmentByDepGroupCode(depGroupCode);
//			// 科室组下的新增科室
//			List<Object[]> newDepList = foreCastApplication.getNewDepartment(forecastYear, depGroupCode);
//			GlobalData.cookie.put("total", depList.size());
//			try {
//				// 循环科室
//				List<Future<Map<String, Object>>> listFuture = new ArrayList<>();
//				ExecutorService pool = Executors.newFixedThreadPool(10);
//				for (int i = 0; i < depList.size(); i++) {
//					IndexCalDTO nDto=(IndexCalDTO) DrgsIndex.copyPropertiesObj(dto);
//					Map<String, Object> depMap = depList.get(i);
//					String depCode=depMap.get("DEP_CODE") == null ? null : depMap.get("DEP_CODE").toString();
//					String depName=depMap.get("DEP_NAME") == null ? null : depMap.get("DEP_NAME").toString();
//					DepartmentCallable c = new DepartmentCallable(nDto, foreCastParam, forecastYear,depCode,depName,hospCode);
//					Future<Map<String, Object>> rf = pool.submit(c);
//					listFuture.add(rf);
//				}
//
//				pool.shutdown();
//				// 获取所有并发任务的运行结果
//				for (Future<Map<String, Object>> rf : listFuture) {
//					resultListDep.add(rf.get());
//					resultListDeps.add(rf.get());
//				}
//				// 新增科室
//				if (newDepList.isEmpty()) {
//					ExecutorService poolnew = Executors.newFixedThreadPool(10);
//					List<Future<Map<String, Object>>> newdepListf = new ArrayList<>();
//					for (Object[] objs : newDepList) {
//						String depCode = objs[0] != null ? objs[0].toString() : "";
//						String depName = objs[1] != null ? objs[1].toString() : "";
//						NewDepartmentCallable c = new NewDepartmentCallable(depCode, depName, forecastYear);
//						Future<Map<String, Object>> fn = poolnew.submit(c);
//						newdepListf.add(fn);
//					}
//					poolnew.shutdown();
//					// 获取所有并发任务的运行结果
//					for (Future<Map<String, Object>> fn : newdepListf) {
//						// 从Future对象上获取任务的返回值，并输出到控制台
//						resultListDep.add(fn.get());
//						resultListDeps.add(fn.get());
//					}
//				}
//			} catch (Exception e) {
//				e.printStackTrace();
//			} finally {
//				for (Map<String, Object> map : resultListDeps) {
//					double hcTotalFundT = map.get("HCTotalFund") != null ? Double.parseDouble(map.get("HCTotalFund").toString()) : 0;
//					double totalxT = map.get("totalxT") != null ? Double.parseDouble(map.get("totalxT").toString()) : 0;
//					double totalFeeT = map.get("totalFeeT") != null ? Double.parseDouble(map.get("totalFeeT").toString()) : 0;
//					double hcTotalFeeT = map.get("hcTotalFeeT") != null ? Double.parseDouble(map.get("hcTotalFeeT").toString()) : 0;
//					double drugFeeT = map.get("drugFeeT") != null ? Double.parseDouble(map.get("drugFeeT").toString()) : 0;
//					double hcDrugFeeT = map.get("hcDrugFeeT") != null ? Double.parseDouble(map.get("hcDrugFeeT").toString()) : 0;
//					double feeEffT = map.get("feeEffT") != null ? Double.parseDouble(map.get("feeEffT").toString()) : 0;
//					double timeEffT = map.get("timeEffT") != null ? Double.parseDouble(map.get("timeEffT").toString()) : 0;
//					double totalCaseCntT = map.get("TotalCaseCnt") != null ? Double.parseDouble(map.get("TotalCaseCnt").toString()) : 0;
//					double hcCaseCntT = map.get("HCCaseCnt") != null ? Double.parseDouble(map.get("HCCaseCnt").toString()) : 0;
//					double drugMateFeeT = map.get("drugMateFeeT") != null ? Double.parseDouble(map.get("drugMateFeeT").toString()) : 0;
//					double hcDrugMateFeeT = map.get("hcDrugMateFeeT") != null ? Double.parseDouble(map.get("hcDrugMateFeeT").toString()) : 0;
//					hcTotalFundTT = hcTotalFundTT + hcTotalFundT;
//					totalxTT = totalxTT + totalxT;
//					totalCaseCntTT = totalCaseCntTT + totalCaseCntT;
//					hcCaseCntTT = hcCaseCntTT + hcCaseCntT;
//					totalFeeTT = totalFeeTT + totalFeeT;
//					hcTotalFeeTT = hcTotalFeeTT + hcTotalFeeT;
//					drugFeeTT = drugFeeTT + drugFeeT;
//					hcDrugFeeTT = hcDrugFeeTT + hcDrugFeeT;
//					feeEffTT = feeEffTT + feeEffT;
//					timeEffTT = timeEffTT + timeEffT;
//					drugMateFeeTT = drugMateFeeTT + drugMateFeeT;
//					hcDrugMateFeeTT = hcDrugMateFeeTT + hcDrugMateFeeT;
//
//					hcTotalFundDT = hcTotalFundDT + hcTotalFundT;
//					totalxDT = totalxDT + totalxT;
//					totalCaseCntDT = totalCaseCntDT + totalCaseCntT;
//					hcCaseCntDT = hcCaseCntDT + hcCaseCntT;
//					totalFeeDT = totalFeeDT + totalFeeT;
//					hcTotalFeeDT = hcTotalFeeDT + hcTotalFeeT;
//					drugFeeDT = drugFeeDT + drugFeeT;
//					hcDrugFeeDT = hcDrugFeeDT + hcDrugFeeT;
//					feeEffDT = feeEffDT + feeEffT;
//					timeEffDT = timeEffDT + timeEffT;
//					drugMateFeeDT = drugMateFeeDT + drugMateFeeT;
//					hcDrugMateFeeDT = hcDrugMateFeeDT + hcDrugMateFeeT;
//				}
//
//				Map<String, Object> depGroupMap = new HashMap<String, Object>();
//				// 全院平均住院日
//				double hospAvgDaysForeCast = totalCaseCntDT != 0 ? totalxDT / totalCaseCntDT : 0;
//				// 全院次均费用
//				double hospAvgFeeForeCast = totalCaseCntDT != 0 ? totalFeeDT / totalCaseCntDT : 0;
//				// 全院医保次均费用
//				double hospHCAvgFeeForeCast = hcCaseCntDT != 0 ? hcTotalFeeDT / hcCaseCntDT : 0;
//				// 非医保患者比例
//				double notHCRatio = (totalCaseCntDT - hcCaseCntDT) / totalCaseCntDT * 100;
//				// 费用消耗指数
//				double feeEff = Arith.div(feeEffDT, totalCaseCntDT, 2);
//				// 时间消耗指数
//				double timeEff = Arith.div(timeEffDT, totalCaseCntDT, 2);
//				// 次均药费
//				double hospAvgDrugFeeForeCast = totalCaseCntDT != 0 ? drugFeeDT / totalCaseCntDT : 0;
//				// 医保次均药费
//				double hospHCAvgDrugFeeForeCast = hcCaseCntDT != 0 ? hcDrugFeeDT / hcCaseCntDT : 0;
//				// 次均药耗费
//				double hospAvgDrugMateFeeForeCast = totalCaseCntDT != 0 ? drugMateFeeDT / totalCaseCntDT : 0;
//				// 医保次均药耗费
//				double hospHCAvgDrugMateFeeForeCast = hcCaseCntDT != 0 ? hcDrugMateFeeDT / hcCaseCntDT : 0;
//
//				depGroupMap.put("depGroupCode", depGroupCode);
//				DepGroup depGroup = depGroupApplication.getDepGroup(depGroupCode);
//				depGroupMap.put("depGroupDesc", depGroup.getDepGroupDesc());
//				Map<String, Object> mResult = getHospDatabyDepCode(dto);
//				
//				depGroupMap.put("AvgDaysly", mResult.get("AvgDays"));
//				depGroupMap.put("AvgFeely", mResult.get("AvgFee"));
//				depGroupMap.put("TotalCaseCntly", mResult.get("TotalCaseCnt"));
//				depGroupMap.put("AvgDrugMateFeely", mResult.get("AvgDrugMateFee"));
//				depGroupMap.put("HCAvgFeely", mResult.get("HCAvgFee"));
//				depGroupMap.put("HCAvgDrugMateFeely", mResult.get("HCAvgDrugMateFee"));
//				depGroupMap.put("HCTotalCaseCntly", mResult.get("HCTotalCaseCnt"));;
//				depGroupMap.put("HCTotalFundly", mResult.get("HCTotalFund"));
//				depGroupMap.put("HCAvgDrugFeely", mResult.get("HCAvgDrugFee"));
//				depGroupMap.put("AvgDrugFeely", mResult.get("AvgDrugFee"));
//				depGroupMap.put("TimeEffly", mResult.get("TimeEff"));
//				depGroupMap.put("FeeEffly", mResult.get("FeeEff"));
//				depGroupMap.put("HCCaseCntly", mResult.get("HCCaseCnt"));
//				
//				depGroupMap.put("HCTotalFund", new DecimalFormat("0").format(hcTotalFundDT));
//				depGroupMap.put("AvgDays", new DecimalFormat("0.00").format(hospAvgDaysForeCast));
//				depGroupMap.put("AvgFee", new DecimalFormat("0.0").format(hospAvgFeeForeCast));
//				depGroupMap.put("HCAvgFee", new DecimalFormat("0.0").format(hospHCAvgFeeForeCast));
//				depGroupMap.put("AvgDrugFee", new DecimalFormat("0.0").format(hospAvgDrugFeeForeCast));
//				depGroupMap.put("HCAvgDrugFee", new DecimalFormat("0.0").format(hospHCAvgDrugFeeForeCast));
//				depGroupMap.put("TotalCaseCnt", new DecimalFormat("0").format(totalCaseCntDT));
//				depGroupMap.put("HCCaseCnt", new DecimalFormat("0").format(hcCaseCntDT));
//				depGroupMap.put("NotHCRatio", new DecimalFormat("0.0").format(notHCRatio));
//				depGroupMap.put("TimeEff", timeEff);
//				depGroupMap.put("FeeEff", feeEff);
//				depGroupMap.put("AvgDrugMateFee", new DecimalFormat("0.0").format(hospAvgDrugMateFeeForeCast));
//				depGroupMap.put("HCAvgDrugMateFee", new DecimalFormat("0.0").format(hospHCAvgDrugMateFeeForeCast));
//				resultListDepGroup.add(depGroupMap);
//			}
//		}
		Map<String, Object> hospMap = new HashMap<String, Object>();
//		// 全院平均住院日
//		double hospAvgDaysForeCast = totalCaseCntTT != 0 ? totalxTT / totalCaseCntTT : 0;
//		// 全院次均费用
//		double hospAvgFeeForeCast = totalCaseCntTT != 0 ? totalFeeTT / totalCaseCntTT : 0;
//		// 全院医保次均费用
//		double hospHCAvgFeeForeCast = hcCaseCntTT != 0 ? hcTotalFeeTT / hcCaseCntTT : 0;
//		// 非医保患者比例
//		double notHCRatio = (totalCaseCntTT - hcCaseCntTT) / totalCaseCntTT * 100;
//		// 费用消耗指数
//		double feeEff = Arith.div(feeEffTT, totalCaseCntTT, 2);
//		// 时间消耗指数
//		double timeEff = Arith.div(timeEffTT, totalCaseCntTT, 2);
//		// 次均药费
//		double hospAvgDrugFeeForeCast = totalCaseCntTT != 0 ? drugFeeTT / totalCaseCntTT : 0;
//		// 医保次均药费
//		double hospHCAvgDrugFeeForeCast = hcCaseCntTT != 0 ? hcDrugFeeTT / hcCaseCntTT : 0;
//		// 次均药耗费
//		double hospAvgDrugMateFeeForeCast = totalCaseCntTT != 0 ? drugMateFeeTT / totalCaseCntTT : 0;
//		// 医保次均药耗费
//		double hospHCAvgDrugMateFeeForeCast = hcCaseCntTT != 0 ? hcDrugMateFeeTT / hcCaseCntTT : 0;
//		hospMap.put("depCode", "hosp");
//		hospMap.put("depDesc", "全院");
//		hospMap.put("HCTotalFund", new DecimalFormat("0").format(hcTotalFundTT));
//		hospMap.put("AvgDays", new DecimalFormat("0.00").format(hospAvgDaysForeCast));
//		hospMap.put("AvgFee", new DecimalFormat("0.0").format(hospAvgFeeForeCast));
//		hospMap.put("HCAvgFee", new DecimalFormat("0.0").format(hospHCAvgFeeForeCast));
//		hospMap.put("AvgDrugFee", new DecimalFormat("0.0").format(hospAvgDrugFeeForeCast));
//		hospMap.put("HCAvgDrugFee", new DecimalFormat("0.0").format(hospHCAvgDrugFeeForeCast));
//		hospMap.put("TotalCaseCnt", new DecimalFormat("0").format(totalCaseCntTT));
//		hospMap.put("HCCaseCnt", new DecimalFormat("0").format(hcCaseCntTT));
//		hospMap.put("NotHCRatio", new DecimalFormat("0.0").format(notHCRatio));
//		hospMap.put("TimeEff", timeEff);
//		hospMap.put("FeeEff", feeEff);
//		hospMap.put("AvgDrugMateFee", new DecimalFormat("0.0").format(hospAvgDrugMateFeeForeCast));
//		hospMap.put("HCAvgDrugMateFee", new DecimalFormat("0.0").format(hospHCAvgDrugMateFeeForeCast));
//		IndexCalDTO dtoh = new IndexCalDTO();
//		dtoh.setHospCode(hospCode);
//		dtoh.setDateFrom(dateFrom);
//		dtoh.setDateTo(dateTo);
//		Map<String, Object> mResult = getHospDatabyDepCode(dtoh);
//		hospMap.put("AvgDaysly", mResult.get("AvgDays"));
//		hospMap.put("AvgFeely", mResult.get("AvgFee"));
//		hospMap.put("TotalCaseCntly", mResult.get("TotalCaseCnt"));
//		hospMap.put("AvgDrugMateFeely", mResult.get("AvgDrugMateFee"));
//		hospMap.put("HCAvgFeely", mResult.get("HCAvgFee"));
//		hospMap.put("HCAvgDrugMateFeely", mResult.get("HCAvgDrugMateFee"));
//		hospMap.put("HCTotalCaseCntly", mResult.get("HCTotalCaseCnt"));;
//		hospMap.put("HCTotalFundly", mResult.get("HCTotalFund"));
//		hospMap.put("HCAvgDrugFeely", mResult.get("HCAvgDrugFee"));
//		hospMap.put("AvgDrugFeely", mResult.get("AvgDrugFee"));
//		hospMap.put("TimeEffly", mResult.get("TimeEff"));
//		hospMap.put("FeeEffly", mResult.get("FeeEff"));
//		hospMap.put("HCCaseCntly", mResult.get("HCCaseCnt"));
		
		// resultMap.putAll(hospMap);
//		resultList.add(hospMap);
		List<Map<String, Object>> hospList = foreCastApplication.foreCastHospital(dateFrom, dateTo, asId, forecastYear, monitorType);
		if(hospList.size()>0){
			Map<String, Object> m = hospList.get(0);
			hospMap.put("depCode", "hosp");
			hospMap.put("depDesc", "全院");
			hospMap.put("HCTotalFund", m.get("HCTOTALFUND"));
			hospMap.put("AvgDays", m.get("AVGDAYS"));
			hospMap.put("AvgFee", m.get("AVGFEE"));
			hospMap.put("HCAvgFee", m.get("HCAVGFEE"));
			hospMap.put("AvgDrugFee", m.get("AVGDRUGFEE"));
			hospMap.put("HCAvgDrugFee", m.get("HCAVGDRUGFEE"));
			hospMap.put("TotalCaseCnt", m.get("TOTALCASECNT"));
			hospMap.put("HCCaseCnt", m.get("HCCASECNT"));
			hospMap.put("notHCRatio", m.get("HCRATIO"));
			hospMap.put("TimeEff", m.get("TIMEEFF"));
			hospMap.put("FeeEff", m.get("FEEEFF"));
			hospMap.put("CMI", m.get("CMI"));
			hospMap.put("AvgDrugMateFee", m.get("DRUGMATERIALFEE"));
			hospMap.put("HCAvgDrugMateFee", m.get("HCDRUGMATERIALFEE"));
		}
		if("depGroup".equals(monitorType)){
			List<Map<String, Object>> depgroupList = foreCastApplication.foreCastDepgroup(dateFrom, dateTo, asId, forecastYear, monitorType);
			for(Map<String, Object> m: depgroupList){
				Map<String, Object> m1 = new HashMap<>();
				m1.put("depGroupCode", m.get("CCODE"));
				m1.put("depGroupDesc", m.get("DDESC"));
				m1.put("HCTotalFund", m.get("HCTOTALFUND"));
				m1.put("AvgDays", m.get("AVGDAYS"));
				m1.put("AvgFee", m.get("AVGFEE"));
				m1.put("HCAvgFee", m.get("HCAVGFEE"));
				m1.put("AvgDrugFee", m.get("AVGDRUGFEE"));
				m1.put("HCAvgDrugFee", m.get("HCAVGDRUGFEE"));
				m1.put("TotalCaseCnt", m.get("TOTALCASECNT"));
				m1.put("HCCaseCnt", m.get("HCCASECNT"));
				m1.put("notHCRatio", m.get("HCRATIO"));
				m1.put("TimeEff", m.get("TIMEEFF"));
				m1.put("FeeEff", m.get("FEEEFF"));
				m1.put("CMI", m.get("CMI"));
				m1.put("AvgDrugMateFee", m.get("DRUGMATERIALFEE"));
				m1.put("HCAvgDrugMateFee", m.get("HCDRUGMATERIALFEE"));
				resultListDepGroup.add(m1);
			}
		}
		List<Map<String, Object>> depList = foreCastApplication.foreCastDep(dateFrom, dateTo, asId, forecastYear, monitorType);
		for(Map<String, Object> m: depList){
			Map<String, Object> m1 = new HashMap<>();
			m1.put("depCode", m.get("CCODE"));
			m1.put("depDesc", m.get("DDESC"));
			m1.put("HCTotalFund", m.get("HCTOTALFUND"));
			m1.put("AvgDays", m.get("AVGDAYS"));
			m1.put("AvgFee", m.get("AVGFEE"));
			m1.put("HCAvgFee", m.get("HCAVGFEE"));
			m1.put("AvgDrugFee", m.get("AVGDRUGFEE"));
			m1.put("HCAvgDrugFee", m.get("HCAVGDRUGFEE"));
			m1.put("TotalCaseCnt", m.get("TOTALCASECNT"));
			m1.put("HCCaseCnt", m.get("HCCASECNT"));
			m1.put("notHCRatio", m.get("HCRATIO"));
			m1.put("TimeEff", m.get("TIMEEFF"));
			m1.put("FeeEff", m.get("FEEEFF"));
			m1.put("CMI", m.get("CMI"));
			m1.put("AvgDrugMateFee", m.get("DRUGMATERIALFEE"));
			m1.put("HCAvgDrugMateFee", m.get("HCDRUGMATERIALFEE"));
			resultListDep.add(m1);
		}
		Map<String, Object> manyResults = new HashMap<>();
		manyResults.put("hosp", hospMap);
		manyResults.put("depGroup", resultListDepGroup);
		manyResults.put("dep", resultListDep);
		GlobalData.cookie.put("states", "success");
		return InvokeResult.success(manyResults);
	}
	/**
	 *  @Discription：将调整参数复制到对应的对象中
	 *  @Author： liuhongjun
	 *  @param foreCastParam
	 *  @param quotaAdjust
	 *  @Date:2018年3月15日下午1:21:30
	 */
	public void setAdjuestParamToCastParam(ForeCastParam foreCastParam, QuotaAdjust quotaAdjust) {

		try {
			foreCastParam.setDepCode(quotaAdjust.getDepCode());
			foreCastParam.setDepGroupCode(quotaAdjust.getParDepGroupCode());
			if ("AvgDays".equals(quotaAdjust.getQuotaCode())) {
				foreCastParam.setAvgDaysParamL(quotaAdjust.getLowValue());
				foreCastParam.setAvgDaysParamH(quotaAdjust.getHighValue());
			}
			if ("AvgFee".equals(quotaAdjust.getQuotaCode())) {
				foreCastParam.setAvgFeeParamL(quotaAdjust.getLowValue());
				foreCastParam.setAvgFeeParamH(quotaAdjust.getHighValue());
			}
			if ("AvgDrugFee".equals(quotaAdjust.getQuotaCode())) {
				foreCastParam.setAvgDrugFeeParamL(quotaAdjust.getLowValue());
				foreCastParam.setAvgDrugFeeParamH(quotaAdjust.getHighValue());
			}
			if ("HCAvgFee".equals(quotaAdjust.getQuotaCode())) {
				foreCastParam.setHcAvgFeeParamL(quotaAdjust.getLowValue());
				foreCastParam.setHcAvgFeeParamH(quotaAdjust.getHighValue());
			}
			if ("HCAvgDrugFee".equals(quotaAdjust.getQuotaCode())) {
				foreCastParam.setHcAvgDrugFeeParamL(quotaAdjust.getLowValue());
				foreCastParam.setHcAvgDrugFeeParamH(quotaAdjust.getHighValue());
			}
			if ("AvgDrugMateFee".equals(quotaAdjust.getQuotaCode())) {
				foreCastParam.setAvgDrugMateFeeParamL(quotaAdjust.getLowValue());
				foreCastParam.setAvgDrugMateFeeParamH(quotaAdjust.getHighValue());
			}
			if ("HCAvgDrugMateFee".equals(quotaAdjust.getQuotaCode())) {
				foreCastParam.setHcAvgDrugMateFeeParamL(quotaAdjust.getLowValue());
				foreCastParam.setHcAvgDrugMateFeeParamH(quotaAdjust.getHighValue());
			}
		}catch (Exception e) {
			e.printStackTrace();
		}
	
	}
	
	/**
	 * @Discription：获取新增科室相关信息监测    
	 * @Author：liuhongjun  
	 * @ClassName: NewDepartmentCallable  
	 * @Date: 2018年3月14日 下午2:45:25  
	 * @Version：3.1.0 DHC.DRGs
	 */
	private class NewDepartmentCallable implements Callable<Map<String, Object>> {
		private String depCode;
		private String depName;
		private String forecastYear;
		
		public NewDepartmentCallable(String depCode, String depName, String year) {
			this.depCode = depCode;
			this.depName = depName;
			this.forecastYear = year;
		}
		
		@Override
		public Map<String, Object> call() throws Exception {
			GlobalData.cookie.put("currentDepName", depName);
			List<Object[]> drgList = foreCastApplication.getNewDepartmentDRGsData(depCode, forecastYear);
			double hcTotalFundT = 0;// 医保总基金
			double totalxT = 0;// 科室总床日数
			double totalCaseCntT = 0;// 总人数
			double hcCaseCntT = 0;// 医保总人数
			double totalFeeT = 0;// 预计总费用
			double hcTotalFeeT = 0;// 预计医保费用
			double drugFeeT = 0;
			double hcDrugFeeT = 0;
			double feeEffT = 0;
			double timeEffT = 0;
			double drugMateFeeT = 0;
			double hcDrugMateFeeT = 0;
			//获取新增床日数
			double addBedDays = foreCastApplication.getAddBedDaysByDep(depCode, forecastYear);
			//获取医保比例
			double hcratio = foreCastApplication.getHcRatioByDep(depCode, forecastYear);
			//获取医保基金比例
			double hcfundratio = foreCastApplication.getHcFundRatioByDep(depCode, forecastYear);
			List<Map<String, Object>> list = new LinkedList<>();
			//计算总床日
			for(Object[] objs: drgList){
				int totalcasecnt = objs[1]!=null?Integer.parseInt(objs[1].toString()):0;
				double avgdays = objs[2]!=null?Double.parseDouble(objs[2].toString()):0;
				totalxT += totalcasecnt*avgdays;
				Map<String, Object> map = new HashMap<>();
				map.put("AvgDays", avgdays);
				map.put("Totalcasecnt", totalcasecnt);
				map.put("drgCode", objs[0]);
				map.put("bedDays", totalcasecnt*avgdays);
				map.put("AvgFee", objs[3]!=null?Double.parseDouble(objs[3].toString()):0);
				map.put("AvgDrugFee", objs[4]!=null?Double.parseDouble(objs[4].toString()):0);
				map.put("AvgDrugMateFee", objs[5]!=null?Double.parseDouble(objs[5].toString()):0);
				list.add(map);
			}
			//计算相关指标
			for(Map<String, Object> m: list){
				//计算床日比例
				int totalcasecnt = (int) m.get("Totalcasecnt");
				double avgdays = (double) m.get("AvgDays");
				double beddays = (double) m.get("bedDays");
				double avgfee = (double) m.get("AvgFee");
				double beddaysratio = totalxT!=0?beddays/totalxT:0;
				double totalcasecntf = (int)(beddaysratio*addBedDays/avgdays);
				double hctotalcasecntf = Arith.round_u(totalcasecntf*hcratio, 0);
				double hctotalfee = (double)m.get("AvgFee")*hctotalcasecntf;
				double totalfee = (double)m.get("AvgFee")*totalcasecntf;
				double hcdrugfee = (double)m.get("AvgDrugFee")*hctotalcasecntf;
				double drugfee = (double)m.get("AvgDrugFee")*totalcasecntf;
				double drugmatefee = (double)m.get("AvgDrugMateFee")*totalcasecntf;
				double hcdrugmatefee = (double)m.get("AvgDrugMateFee")*hctotalcasecntf;
				System.out.println(m.get("drgCode")+":"+totalcasecntf+":"+avgdays+":"+totalcasecnt);
				totalCaseCntT += totalcasecntf;
				hcCaseCntT += hctotalcasecntf;
				totalFeeT += totalfee;
				hcTotalFeeT += hctotalfee;
				drugFeeT += drugfee;
				hcDrugFeeT += hcdrugfee;
				hcTotalFundT += hcfundratio*hctotalfee;
				drugMateFeeT += drugmatefee;
				hcDrugMateFeeT += hcdrugmatefee;
				// 测算时间效率和费用效率
				Map<String, Object> nan =  drgsNanMap.get(m.get("drgCode"));
				double avgFeeNan = nan != null ? (nan.get("AvgFee") != null ? Double.parseDouble(nan.get("AvgFee").toString()) : 0) : 0;
				double avgDaysNan = nan != null ? (nan.get("AvgDays") != null ? Double.parseDouble(nan.get("AvgDays").toString()) : 0) : 0;
				feeEffT = feeEffT + Arith.div(avgfee, avgFeeNan) * totalcasecntf;
				timeEffT = timeEffT + Arith.div(avgdays, avgDaysNan) * totalcasecntf;
			}
			// 科室平均住院日
			double depAvgDaysForeCast = totalCaseCntT != 0 ? (addBedDays) / totalCaseCntT : 0;
			// 科室次均费用
			double depAvgFeeForeCast = totalCaseCntT != 0 ? totalFeeT / totalCaseCntT : 0;
			// 科室医保次均费用
			double depHCAvgFeeForeCast = hcCaseCntT != 0 ? hcTotalFeeT / hcCaseCntT : 0;
			// 非医保患者比例
			double notHCRatio = (totalCaseCntT - hcCaseCntT) / totalCaseCntT * 100;
			// 费用消耗指数
			double feeEff = Arith.div(feeEffT, totalCaseCntT, 2);
			// 时间消耗指数
			double timeEff = Arith.div(timeEffT, totalCaseCntT, 2);
			// 次均药费
			double avgDrugFee = totalCaseCntT!=0?drugFeeT/totalCaseCntT:0;
			//医保次均药费
			double hcAvgDrugFee = hcCaseCntT!=0?hcDrugFeeT/hcCaseCntT:0;
			// 次均药耗费
			double avgDrugMateFee = totalCaseCntT!=0?drugMateFeeT/totalCaseCntT:0;
			//医保次均药耗费
			double hcAvgDrugMateFee = hcCaseCntT!=0?hcDrugMateFeeT/hcCaseCntT:0;
			Map<String, Object> resultMap = new HashMap<>();
			resultMap.put("depCode", depCode);
			resultMap.put("depDesc", depName);
			resultMap.put("HCTotalFund", new DecimalFormat("0").format(hcTotalFundT));
			resultMap.put("AvgDays", new DecimalFormat("0.00").format(depAvgDaysForeCast));
			resultMap.put("AvgFee", new DecimalFormat("0.0").format(depAvgFeeForeCast));
			resultMap.put("HCAvgFee", new DecimalFormat("0.0").format(depHCAvgFeeForeCast));
			resultMap.put("AvgDrugFee", new DecimalFormat("0.0").format(avgDrugFee));
			resultMap.put("HCAvgDrugFee", new DecimalFormat("0.0").format(hcAvgDrugFee));
			resultMap.put("TotalCaseCnt", new DecimalFormat("0").format(totalCaseCntT));
			resultMap.put("HCCaseCnt", new DecimalFormat("0").format(hcCaseCntT));
			resultMap.put("NotHCRatio", new DecimalFormat("0.0").format(notHCRatio));
			resultMap.put("TimeEff", timeEff);
			resultMap.put("FeeEff", feeEff);
			resultMap.put("AvgDrugMateFee", new DecimalFormat("0.0").format(avgDrugMateFee));
			resultMap.put("HCAvgDrugMateFee", new DecimalFormat("0.0").format(hcAvgDrugMateFee));
			resultMap.put("totalxT", totalxT);
			resultMap.put("totalFeeT", totalFeeT);
			resultMap.put("hcTotalFeeT", hcTotalFeeT);
			resultMap.put("drugFeeT", drugFeeT);
			resultMap.put("hcDrugFeeT", hcDrugFeeT);
			resultMap.put("feeEffT", feeEffT);
			resultMap.put("timeEffT", timeEffT);
			resultMap.put("drugMateFeeT", drugMateFeeT);
			resultMap.put("hcDrugMateFeeT", hcDrugMateFeeT);
//			synchronized (depCode) {
//				oneSize++;
//				GlobalData.cookie.put("currentDepCount", oneSize);
//			}
			return resultMap;
		}
		
	}

	/**
	 * @desp     ：    循环科室测算
	 * @Author   ：liuhongjun  
	 * @ClassName: DepartmentCallable  
	 * @Date     : 2018年3月13日 下午8:38:18  
	 * @Version  ：3.0.0 DHC.DRGs
	 */
	private class DepartmentCallable implements Callable<Map<String, Object>> {
		private String depName;
		private String depCode;
		private IndexCalDTO dto;
		private ForeCastParam foreCastParam;
		private String forecastYear;
		private String hospCode;

		public DepartmentCallable(IndexCalDTO indexCalDTO, ForeCastParam foreCastParam, String forecastYear,String depCode,String depName,String hospCode) {
			this.depCode=depCode;
			this.depName=depName;
			this.dto = indexCalDTO;
			this.foreCastParam =foreCastParam;
			this.forecastYear = forecastYear;
			this.hospCode=hospCode;
		}

		@Override
		public Map<String, Object> call() throws Exception {
			// 获取科室自有的参数,没有则使用自己的上属科室组的
			List<QuotaAdjust> quotaAdjustList = quotaAdjustApplication.getForeCastParamByDep(depCode, forecastYear);
			if (quotaAdjustList != null) {
				for (QuotaAdjust q : quotaAdjustList) {
					setAdjuestParamToCastParam(this.foreCastParam, q);
				}
			}
			Map<String, Object> depMap = new HashMap<>();
			depMap.put("depCode", depCode);
			depMap.put("depDesc", depName);
			GlobalData.cookie.put("currentDepName", depName);
			dto.setPardepCode(depCode);
			dto.setMonitorType("dep");
			dto.setQuotaCode("ForeCast");
			dto.setCompareType("std");
			dto.setMsCode("std_computer");
			dto.setHospCode(hospCode);
			dto.setIsGetCc("1");
			// 根据科室代码获取科室全院指标值，用于页面的上升下降比较
			Map<String, Object> mResult = getHospDatabyDepCode(dto);
			depMap.put("AvgDaysly", mResult.get("AvgDays"));
			depMap.put("AvgFeely", mResult.get("AvgFee"));
			depMap.put("TotalCaseCntly", mResult.get("TotalCaseCnt"));
			depMap.put("AvgDrugMateFeely", mResult.get("AvgDrugMateFee"));
			depMap.put("HCAvgFeely", mResult.get("HCAvgFee"));
			depMap.put("HCAvgDrugMateFeely", mResult.get("HCAvgDrugMateFee"));
			depMap.put("HCTotalCaseCntly", mResult.get("HCTotalCaseCnt"));;
			depMap.put("HCTotalFundly", mResult.get("HCTotalFund"));
			depMap.put("HCAvgDrugFeely", mResult.get("HCAvgDrugFee"));
			depMap.put("AvgDrugFeely", mResult.get("AvgDrugFee"));
			depMap.put("TimeEffly", mResult.get("TimeEff"));
			depMap.put("FeeEffly", mResult.get("FeeEff"));
			depMap.put("HCCaseCntly", mResult.get("HCCaseCnt"));
			// 获取该科室组下该科室的测算指标，如科室组1下的心内1
			List<ForeCast> depForeCastList = getMonitorResult(dto);
			ForeCast depForeCast = depForeCastList.size() > 0 ? depForeCastList.get(0) : new ForeCast();
			// 获取该科室组下科室增加床日数
			double addDepBedDays = foreCastApplication.getAddBedDaysByDep(depCode, forecastYear);
			List<ForeCast> drgForeList = new LinkedList<ForeCast>();
			double depSpareBedDays = 0;// 该科室节省床日数
			try {
				double depAvgDays = depForeCast.getAvgDays()==null?0:depForeCast.getAvgDays();// 科室平均住院日
				double depTotalDays = depForeCast.getTotalDays()==null?0:depForeCast.getTotalDays();// 科室总床位数
				double hcTotalFundT = 0;// 医保总基金
				double totalxT = 0;// 科室总床日数
				double totalCaseCntT = 0;// 总人数
				double hcCaseCntT = 0;// 医保总人数
				double totalFeeT = 0;// 预计总费用
				double hcTotalFeeT = 0;// 预计医保费用
				double drugFeeT = 0;// 预计药品费用
				double hcDrugFeeT = 0; // 预计医保药品费用
				double feeEffT = 0;// 预计费用消耗指数
				double timeEffT = 0;// 预计时间消耗指数
				double drugMateFeeT = 0;// 预计药耗费用
				double hcDrugMateFeeT = 0;//预计医保药耗费用
				
				// 查询该科室组下该科室下的DRGs信息
				dto.setMonitorType("drgs");
				dto.setQuotaCode("ForeCast");
				dto.setMsCode("std_computer");
				dto.setCompareType("std");
				dto.setHospCode(hospCode);
				dto.setIsGetCc("1");
				drgForeList = getMonitorResult(dto);
				// 计算节省床日数
				for (ForeCast foreCast : drgForeList) {
					double avgDaysValue = foreCast.getAvgDays() != null ? foreCast.getAvgDays() : 0;//病组的实际平均住院日
					double avgDaysBenchmark = foreCast.getAvgDaysBenchmark() != null ? foreCast.getAvgDaysBenchmark() : 0;//病组的标杆值
					double totalCaseCnt = foreCast.getTotalCaseCnt() != null ? foreCast.getTotalCaseCnt() : 0;//病组实际入组病例数
					if (avgDaysBenchmark != 0 && avgDaysValue > avgDaysBenchmark) {
						// 根据调整参数计算该病组的调整后的住院日
						double avgDaysParam = foreCastParam.getAvgDaysParamH() != null ? (foreCastParam.getAvgDaysParamH() / 100) : 0;
						depSpareBedDays = depSpareBedDays + (avgDaysValue - avgDaysBenchmark) * avgDaysParam * totalCaseCnt;
					} else if (avgDaysBenchmark != 0 && avgDaysValue <= avgDaysBenchmark) {
						double avgDaysParam = foreCastParam.getAvgDaysParamL() != null ? (foreCastParam.getAvgDaysParamL() / 100) : 0;
						depSpareBedDays = depSpareBedDays + (avgDaysValue - avgDaysBenchmark) * avgDaysParam * totalCaseCnt;
					}
				}
				// 计算该科室下所有病组的调整后的指标值
				for (ForeCast f : drgForeList) {
					ForeCast drgF = drgsMap.get(f.getDrgCode()) != null ? (ForeCast) drgsMap.get(f.getDrgCode()) : new ForeCast();
					// 获取调整参数（病种）
					ForeCastParam foreCastParamDis = this.foreCastParam;
					// 计算预期人数
					double foreHCCaseCnt = 0;// 预计病组医保人数
					double foreCaseCnt = 0;// 预计病组的总人数
					double totalCaseCnt = f.getTotalCaseCnt() != null ? f.getTotalCaseCnt() : 0;// 病组实际人数
					double avgDays = f.getAvgDays() != null ? f.getAvgDays() : 0;// 病组实际住院日
					double avgDaysBenchmark = f.getAvgDaysBenchmark() != null ? f.getAvgDaysBenchmark() : 0;//病组标杆住院日
					double avgDaysParam = 0;
					if (avgDaysBenchmark != 0 && avgDays > avgDaysBenchmark) {
						avgDaysParam = foreCastParamDis.getAvgDaysParamH() != null ? (foreCastParamDis.getAvgDaysParamH() / 100) : 0;
					} else if (avgDaysBenchmark != 0 && avgDays <= avgDaysBenchmark) {
						avgDaysParam = foreCastParamDis.getAvgDaysParamL() != null ? (foreCastParamDis.getAvgDaysParamL() / 100) : 0;
					}
					double avgDaysForeCast = avgDays - (avgDays - avgDaysBenchmark) * avgDaysParam;//病组调整后的平均住院日
					
					double addBedDays = (depAvgDays != 0) ? Arith.div((depSpareBedDays + addDepBedDays) * avgDays * totalCaseCnt, depTotalDays, 10) : 0;
					double addCaseCnt = (avgDaysForeCast != 0) ? (int) (addBedDays / avgDaysForeCast) : 0;
					drgF.setAvgDaysAdjustValue(getAvgValueByCaseCnt(totalCaseCnt, avgDaysForeCast, drgF.getTotalCaseCnt() == null ? 0 : drgF.getTotalCaseCnt(), drgF.getAvgDaysAdjustValue() == null ? 0 : drgF.getAvgDaysAdjustValue()));
					foreCaseCnt = totalCaseCnt + (int) addCaseCnt;
					double hcCountRatio = f.getHcCountRatio() != null ? f.getHcCountRatio() : 0;
					totalCaseCntT = totalCaseCntT + foreCaseCnt;
					foreHCCaseCnt = Arith.mul(foreCaseCnt, hcCountRatio);
					foreHCCaseCnt = Arith.round_u(foreHCCaseCnt, 0);
					hcCaseCntT = hcCaseCntT + foreHCCaseCnt;
					drgF.setTotalCaseCntAdjustValue(foreCaseCnt + (drgF.getTotalCaseCnt() == null ? 0 : drgF.getTotalCaseCnt()));
					drgF.setHcCaseCntAdjustValue(foreHCCaseCnt + (drgF.getTotalCaseCnt() == null ? 0 : drgF.getTotalCaseCnt()));
					// 总床日
					double totalx = totalCaseCnt * avgDays + addBedDays;
					totalxT = totalxT + totalx;

					// 计算次均费用
					double avgFee = f.getAvgFee() != null ? f.getAvgFee() : 0;
					double avgFeeBenchmark = f.getAvgFeeBenchmark() != null ? f.getAvgFeeBenchmark() : 0;
					double avgFeeParam = 0;
					if (avgFeeBenchmark != 0 && avgFee > avgFeeBenchmark) {
						avgFeeParam = foreCastParamDis.getAvgFeeParamH() != null ? (foreCastParamDis.getAvgFeeParamH() / 100) : 0;
					} else if (avgFeeBenchmark != 0 && avgFee <= avgFeeBenchmark) {
						avgFeeParam = foreCastParamDis.getAvgFeeParamL() != null ? (foreCastParamDis.getAvgFeeParamL() / 100) : 0;
					}
					double avgFeeForeCast = 0;
					avgFeeForeCast = avgFee - (avgFee - avgFeeBenchmark) * avgFeeParam;
					drgF.setAvgFeeAdjustValue(
							getAvgValueByCaseCnt(totalCaseCnt, avgFeeForeCast, drgF.getTotalCaseCnt() == null ? 0 : drgF.getTotalCaseCnt(), drgF.getAvgFeeAdjustValue() == null ? 0 : drgF.getAvgFeeAdjustValue()));

					// 总费用
					double totalFee = avgFeeForeCast * foreCaseCnt;
					totalFeeT = totalFeeT + totalFee;

					// 计算医保次均费用
					double hcAvgFee = f.getHcAvgFee() != null ? f.getHcAvgFee() : 0;
					double hcAvgFeeParam = 0;
					if (avgFeeBenchmark != 0 && hcAvgFee > avgFeeBenchmark) {
						hcAvgFeeParam = foreCastParamDis.getHcAvgFeeParamH() != null ? (foreCastParamDis.getHcAvgFeeParamH() / 100) : 0;
					} else if (avgFeeBenchmark != 0 && hcAvgFee <= avgFeeBenchmark) {
						hcAvgFeeParam = foreCastParamDis.getHcAvgFeeParamL() != null ? (foreCastParamDis.getHcAvgFeeParamL() / 100) : 0;
					}

					double hcAvgFeeForeCast = 0;
					hcAvgFeeForeCast = hcAvgFee - (hcAvgFee - avgFeeBenchmark) * hcAvgFeeParam;
					drgF.setHcAvgFeeAdjustValue(getAvgValueByCaseCnt(totalCaseCnt, hcAvgFeeForeCast, drgF.getTotalCaseCnt() == null ? 0 : drgF.getTotalCaseCnt(), drgF.getHcAvgFeeAdjustValue() == null ? 0 : drgF.getHcAvgFeeAdjustValue()));

					// 医保总费用
					double hcTotalFee = hcAvgFeeForeCast * foreHCCaseCnt;
					hcTotalFeeT = hcTotalFeeT + hcTotalFee;
					// 计算病组平均基金
					double HCCaseCnt = f.getHcCaseCnt();
					double hcAvgTotalFund = HCCaseCnt != 0 ? (f.getHcTotalFund() / HCCaseCnt) : 0;
					double hcTotalFundRation = Arith.div(hcAvgTotalFund, hcAvgFee); // 基金占比
					double hcTotalFund = hcTotalFundRation * hcAvgFeeForeCast * foreHCCaseCnt;
					hcTotalFundT = hcTotalFundT + hcTotalFund;
					drgF.setHcTotalFundAdjustValue(hcTotalFund + (drgF.getHcTotalFund() == null ? 0 : drgF.getHcTotalFund()));
					// 计算次均药费
					double drugFee = f.getDrugFee() != null ? f.getDrugFee() : 0;
					double drugFeeBenchmark = f.getDrugFeeBenchmark() != null ? f.getDrugFeeBenchmark() : 0;
					double drugFeeParam = 0;
					if (drugFeeBenchmark != 0 && drugFee > drugFeeBenchmark) {
						drugFeeParam = foreCastParamDis.getAvgDrugFeeParamH() != null ? (foreCastParamDis.getAvgDrugFeeParamH() / 100) : 0;
					} else if (drugFeeBenchmark != 0 && drugFee <= drugFeeBenchmark) {
						drugFeeParam = foreCastParamDis.getAvgDrugFeeParamL() != null ? (foreCastParamDis.getAvgDrugFeeParamL() / 100) : 0;
					}

					double drugFeeForeCast = drugFee - (drugFee - drugFeeBenchmark) * drugFeeParam;
					drugFeeT = drugFeeT + drugFeeForeCast * foreCaseCnt;
					drgF.setDrugFeeAdjustValue((drugFeeForeCast) + (drgF.getDrugFeeAdjustValue() == null ? 0 : drgF.getDrugFeeAdjustValue()));

					// 医保次均药费
					double hcDrugFee = f.getHcDrugFee() != null ? f.getHcDrugFee() : 0;
					hcDrugFee = Arith.round(hcDrugFee, 3);
					double hcDrugFeeParam = 0;
					if (drugFeeBenchmark != 0 && hcDrugFee > drugFeeBenchmark) {
						hcDrugFeeParam = foreCastParamDis.getHcAvgDrugFeeParamH() != null ? (foreCastParamDis.getHcAvgDrugFeeParamH() / 100) : 0;
					} else if (drugFeeBenchmark != 0 && hcDrugFee <= drugFeeBenchmark) {
						hcDrugFeeParam = foreCastParamDis.getHcAvgDrugFeeParamL() != null ? (foreCastParamDis.getHcAvgDrugFeeParamL() / 100) : 0;
					}
					double hcDrugFeeForeCast = hcDrugFee - (hcDrugFee - drugFeeBenchmark) * hcDrugFeeParam;
					hcDrugFeeT = hcDrugFeeT + hcDrugFeeForeCast * foreHCCaseCnt;
					drgF.setHcDrugFeeAdjustValue(hcDrugFeeForeCast + (drgF.getHcDrugFeeAdjustValue() == null ? 0 : drgF.getHcDrugFeeAdjustValue()));
					// 测算时间效率和费用效率
					Map<String, Object> nan =drgsNanMap.get(f.getDrgCode());
					double avgFeeNan = nan != null ? (nan.get("AvgFee") != null ? Double.parseDouble(nan.get("AvgFee").toString()) : 0) : 0;
					double avgDaysNan = nan != null ? (nan.get("AvgDays") != null ? Double.parseDouble(nan.get("AvgDays").toString()) : 0) : 0;
					feeEffT = feeEffT + Arith.div(avgFeeForeCast, avgFeeNan) * foreCaseCnt;
					timeEffT = timeEffT + Arith.div(avgDaysForeCast, avgDaysNan) * foreCaseCnt;
					drgF.setFeeEffAdjustValue(Arith.div(avgFeeForeCast, avgFeeNan) * foreCaseCnt);
					drgF.setTimeEffAdjustValue(Arith.div(avgDaysForeCast, avgDaysNan) * foreCaseCnt);

					// 计算次均药耗费
					double drugMateFee = f.getDrugMateFee() != null ? f.getDrugMateFee() : 0;
					double drugMateFeeBenchmark = f.getDrugMateFeeBenchmark() != null ? f.getDrugMateFeeBenchmark() : 0;
					double drugMateFeeParam = 0;
					if (drugMateFeeBenchmark != 0 && drugMateFee > drugMateFeeBenchmark) {
						drugMateFeeParam = foreCastParamDis.getAvgDrugFeeParamH() != null ? (foreCastParamDis.getAvgDrugMateFeeParamH() / 100) : 0;
					} else if (drugMateFeeBenchmark != 0 && drugFee <= drugMateFeeBenchmark) {
						drugMateFeeParam = foreCastParamDis.getAvgDrugMateFeeParamL() != null ? (foreCastParamDis.getAvgDrugMateFeeParamL() / 100) : 0;
					}

					double drugMateFeeForeCast = drugMateFee - (drugMateFee - drugMateFeeBenchmark) * drugMateFeeParam;
					drugMateFeeT = drugMateFeeT + drugMateFeeForeCast * foreCaseCnt;
					drgF.setDrugMateFeeAdjustValue((drugMateFeeForeCast) + (drgF.getDrugMateFeeAdjustValue() == null ? 0 : drgF.getDrugMateFeeAdjustValue()));

					// 医保次均药耗费
					double hcDrugMateFee = f.getHcDrugMateFee() != null ? f.getHcDrugMateFee() : 0;
					hcDrugMateFee = Arith.round(hcDrugMateFee, 3);
					double hcDrugMateFeeBenchmark = f.getHcDrugMateFeeBenchmark() != null ? f.getHcDrugMateFeeBenchmark() : 0;
					double hcDrugMateFeeParam = 0;
					if (drugMateFeeBenchmark != 0 && hcDrugMateFee > hcDrugMateFeeBenchmark) {
						hcDrugMateFeeParam = foreCastParamDis.getHcAvgDrugMateFeeParamH() != null ? (foreCastParamDis.getHcAvgDrugMateFeeParamH() / 100) : 0;
					} else if (drugMateFeeBenchmark != 0 && hcDrugMateFee <= hcDrugMateFeeBenchmark) {
						hcDrugMateFeeParam = foreCastParamDis.getHcAvgDrugMateFeeParamL() != null ? (foreCastParamDis.getHcAvgDrugMateFeeParamL() / 100) : 0;
					}
					double hcDrugMateFeeForeCast = hcDrugMateFee - (hcDrugMateFee - drugMateFeeBenchmark) * hcDrugMateFeeParam;
					hcDrugMateFeeT = hcDrugMateFeeT + hcDrugMateFeeForeCast * foreHCCaseCnt;
					drgF.setHcDrugMateFeeAdjustValue(hcDrugMateFeeForeCast + (drgF.getHcDrugMateFeeAdjustValue() == null ? 0 : drgF.getHcDrugMateFeeAdjustValue()));
					drgsMap.put(f.getDrgCode(), drgF);
				}
				// 科室平均住院日
				double depAvgDaysForeCast = totalCaseCntT != 0 ? (totalxT + addDepBedDays) / totalCaseCntT : 0;
				// 科室次均费用
				double depAvgFeeForeCast = totalCaseCntT != 0 ? totalFeeT / totalCaseCntT : 0;
				// 科室医保次均费用
				double depHCAvgFeeForeCast = hcCaseCntT != 0 ? hcTotalFeeT / hcCaseCntT : 0;
				// 非医保患者比例
				double notHCRatio = (totalCaseCntT - hcCaseCntT) / totalCaseCntT * 100;
				// 费用消耗指数
				double feeEff = Arith.div(feeEffT, totalCaseCntT, 2);
				// 时间消耗指数
				double timeEff = Arith.div(timeEffT, totalCaseCntT, 2);
				// 次均药费
				double avgDrugFee = totalCaseCntT != 0 ? drugFeeT / totalCaseCntT : 0;
				// 医保次均药费
				double hcAvgDrugFee = hcCaseCntT != 0 ? hcDrugFeeT / hcCaseCntT : 0;
				// 次均药耗费
				double avgDrugMateFee = totalCaseCntT != 0 ? drugMateFeeT / totalCaseCntT : 0;
				// 医保次均药耗费
				double hcAvgMateDrugFee = hcCaseCntT != 0 ? hcDrugMateFeeT / hcCaseCntT : 0;

				depMap.put("HCTotalFund", new DecimalFormat("0").format(hcTotalFundT));
				depMap.put("AvgDays", new DecimalFormat("0.00").format(depAvgDaysForeCast));
				depMap.put("AvgFee", new DecimalFormat("0.0").format(depAvgFeeForeCast));
				depMap.put("HCAvgFee", new DecimalFormat("0.0").format(depHCAvgFeeForeCast));
				depMap.put("AvgDrugFee", new DecimalFormat("0.0").format(avgDrugFee));
				depMap.put("HCAvgDrugFee", new DecimalFormat("0.0").format(hcAvgDrugFee));
				depMap.put("TotalCaseCnt", new DecimalFormat("0").format(totalCaseCntT));
				depMap.put("HCCaseCnt", new DecimalFormat("0").format(hcCaseCntT));
				depMap.put("NotHCRatio", new DecimalFormat("0.0").format(notHCRatio));
				depMap.put("TimeEff", timeEff);
				depMap.put("FeeEff", feeEff);
				depMap.put("AvgDrugMateFee", new DecimalFormat("0.0").format(avgDrugMateFee));
				depMap.put("HCAvgDrugMateFee", new DecimalFormat("0.0").format(hcAvgMateDrugFee));
				depMap.put("totalxT", totalxT);
				depMap.put("totalFeeT", totalFeeT);
				depMap.put("hcTotalFeeT", hcTotalFeeT);
				depMap.put("drugFeeT", drugFeeT);
				depMap.put("hcDrugFeeT", hcDrugFeeT);
				depMap.put("feeEffT", feeEffT);
				depMap.put("timeEffT", timeEffT);
				depMap.put("drugMateFeeT", drugMateFeeT);
				depMap.put("hcDrugMateFeeT", hcDrugMateFeeT);
//				synchronized (depCode) {
//					oneSize++;
//					GlobalData.cookie.put("currentDepCount", oneSize);
//				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			return depMap;
		}
	}

	private double getAvgValueByCaseCnt(double caseCnt1, double value1, double caseCnt2, double value2) {
		double totalCaseCnt = caseCnt1 + caseCnt2;
		double value = Arith.div(caseCnt1, totalCaseCnt, 2) * value1 + Arith.div(caseCnt2, totalCaseCnt, 2) * value2;
		return Arith.round(value, 2);
	}

/**
 * 
 *  @Discription：获取科室下的检测指标
 *  @Author： liuhongjun
 *  @param dto
 *  @return
 *  @Date:2018年3月14日上午8:41:02
 */
	private List<ForeCast> getMonitorResult(IndexCalDTO dto) {
		List<ForeCast> resultList = new LinkedList<>();
		List<Map<String, Object>> mapList = drgsIndexCalFacade.indexCal(dto);
		Collections.sort(mapList, new MapComparatorImpl("TotalCaseCnt", "desc"));
		if("drgs".equals(dto.getMonitorType())){
			for (Map<String, Object> obj : mapList) {
				ForeCast forecast = new ForeCast();
				forecast.setDrgCode(obj.get("ccode")!=null?obj.get("ccode").toString():"");
				forecast.setAvgDays(obj.get("AvgDays") != null ? Double.parseDouble(obj.get("AvgDays").toString()) : 0);
				forecast.setAvgFee(obj.get("AvgFee") != null ? Double.parseDouble(obj.get("AvgFee").toString()) : 0);
				forecast.setDrugFee(obj.get("AvgDrugFee") != null ? Double.parseDouble(obj.get("AvgDrugFee").toString()) : 0);
				forecast.setTotalCaseCnt(obj.get("TotalCaseCnt") != null ? Double.parseDouble(obj.get("TotalCaseCnt").toString()) : 0);
				forecast.setHcAvgFee(obj.get("HCAvgFee") != null ? Double.parseDouble(obj.get("HCAvgFee").toString()) : 0);
				forecast.setHcDrugFee(obj.get("HCAvgDrugFee") != null ? Double.parseDouble(obj.get("HCAvgDrugFee").toString()) : 0);
				forecast.setHcTotalFund(obj.get("HCTotalFund") != null ? Double.parseDouble(obj.get("HCTotalFund").toString()) : 0);
				forecast.setHcCaseCnt(obj.get("HCTotalCaseCnt") != null ? Double.parseDouble(obj.get("HCTotalCaseCnt").toString()) : 0);
				forecast.setTotalDays(obj.get("TotalDays") != null ? Double.parseDouble(obj.get("TotalDays").toString()) : 0);
				forecast.setDrugMateFee(obj.get("AvgDrugMateFee") != null ? Double.parseDouble(obj.get("AvgDrugMateFee").toString()) : 0);
				forecast.setHcDrugMateFee(obj.get("HCAvgDrugMateFee") != null ? Double.parseDouble(obj.get("HCAvgDrugMateFee").toString()) : 0);

				forecast.setAvgDaysBenchmark(obj.get("AvgDayscc") != null ? Double.parseDouble(obj.get("AvgDayscc").toString()) : 0);
				forecast.setAvgFeeBenchmark(obj.get("AvgFeecc") != null ? Double.parseDouble(obj.get("AvgFeecc").toString()) : 0);
				forecast.setDrugFeeBenchmark(obj.get("DrugFeecc") != null ? Double.parseDouble(obj.get("DrugFeecc").toString()) : 0);
				forecast.setHcAvgFeeBenchmark(obj.get("HCAvgFeecc") != null ? Double.parseDouble(obj.get("HCAvgFeecc").toString()) : 0);
				forecast.setHcDrugFeeBenchmark(obj.get("HCDrugFeecc") != null ? Double.parseDouble(obj.get("HCDrugFeecc").toString()) : 0);
				forecast.setDrugMateFeeBenchmark(obj.get("DrugMateFeecc") != null ? Double.parseDouble(obj.get("DrugMateFeecc").toString()) : 0);
				forecast.setHcDrugMateFeeBenchmark(obj.get("HCDrugMateFeecc") != null ? Double.parseDouble(obj.get("HCDrugMateFeecc").toString()) : 0);
				resultList.add(forecast);
			}
		}else{
			for (Map<String, Object> obj : mapList) {
				ForeCast forecast = new ForeCast();
				forecast.setDrgCode(obj.get("ccode")!=null?obj.get("ccode").toString():"");
				forecast.setAvgDays(obj.get("AvgDays") != null ? Double.parseDouble(obj.get("AvgDays").toString()) : 0);
				forecast.setAvgFee(obj.get("AvgFee") != null ? Double.parseDouble(obj.get("AvgFee").toString()) : 0);
				forecast.setDrugFee(obj.get("AvgDrugFee") != null ? Double.parseDouble(obj.get("AvgDrugFee").toString()) : 0);
				forecast.setTotalCaseCnt(obj.get("TotalCaseCnt") != null ? Double.parseDouble(obj.get("TotalCaseCnt").toString()) : 0);
				forecast.setHcAvgFee(obj.get("HCAvgFee") != null ? Double.parseDouble(obj.get("HCAvgFee").toString()) : 0);
				forecast.setHcDrugFee(obj.get("HCAvgDrugFee") != null ? Double.parseDouble(obj.get("HCAvgDrugFee").toString()) : 0);
				forecast.setHcTotalFund(obj.get("HCTotalFund") != null ? Double.parseDouble(obj.get("HCTotalFund").toString()) : 0);
				forecast.setHcCaseCnt(obj.get("HCTotalCaseCnt") != null ? Double.parseDouble(obj.get("HCTotalCaseCnt").toString()) : 0);
				forecast.setTotalDays(obj.get("TotalDays") != null ? Double.parseDouble(obj.get("TotalDays").toString()) : 0);
				forecast.setDrugMateFee(obj.get("AvgDrugMateFee") != null ? Double.parseDouble(obj.get("AvgDrugMateFee").toString()) : 0);
				forecast.setHcDrugMateFee(obj.get("HCAvgDrugMateFee") != null ? Double.parseDouble(obj.get("HCAvgDrugMateFee").toString()) : 0);

				forecast.setAvgDaysBenchmark(obj.get("AvgDayscc") != null ? Double.parseDouble(obj.get("AvgDayscc").toString()) : 0);
				forecast.setAvgFeeBenchmark(obj.get("AvgFeecc") != null ? Double.parseDouble(obj.get("AvgFeecc").toString()) : 0);
				forecast.setDrugFeeBenchmark(obj.get("DrugFeecc") != null ? Double.parseDouble(obj.get("DrugFeecc").toString()) : 0);
				forecast.setHcAvgFeeBenchmark(obj.get("HCAvgFeecc") != null ? Double.parseDouble(obj.get("HCAvgFeecc").toString()) : 0);
				forecast.setHcDrugFeeBenchmark(obj.get("HCDrugFeecc") != null ? Double.parseDouble(obj.get("HCDrugFeecc").toString()) : 0);
				forecast.setDrugMateFeeBenchmark(obj.get("DrugMateFeecc") != null ? Double.parseDouble(obj.get("DrugMateFeecc").toString()) : 0);
				forecast.setHcDrugMateFeeBenchmark(obj.get("HCDrugMateFeecc") != null ? Double.parseDouble(obj.get("HCDrugMateFeecc").toString()) : 0);
				resultList.add(forecast);
			}
		}	
		return resultList;
	}
/**
 * 
 *  @Description：获取科室组调整参数
 *  @Author LiuHongJun  
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#findAllDepGroupData(com.dhcc.DRGsHosp.facade.dto.IndexCalDTO)
 */
	@Override
	public List<Map<String, Object>> findDepGroupForeCast(String dateFrom,String dateTo,String forecastYear, String monitorType) {
		IndexCalDTO dto=new IndexCalDTO();
		String planYear=forecastYear;
		List<Map<String, Object>> resultList = new LinkedList<>();
		dto.setDateFrom(dateFrom);
		dto.setDateTo(dateTo);
		dto.setMonitorType(monitorType);
		dto.setQuotaCode("TotalCaseCnt");
		dto.setIsGetCc("0");
		List<Map<String, Object>> depGroupList = drgsIndexCalFacade.indexCal(dto);
		for (Map<String, Object> depGroup : depGroupList) {
			if(depGroup.get("ccode")==null) continue;
			Map<String, Object> map = new HashMap<>();
			map.put("depGroupCode", depGroup.get("ccode"));//科室暂时也用depgroupCode存放,注意
			map.put("depGroupDesc", depGroup.get("ddesc"));
			map.put("TotalCaseCnt", depGroup.get("QuotaValue"));
			QuotaAdjust q = new QuotaAdjust();
			if("depGroup".equals(monitorType)){
				q.setParDepGroupCode(depGroup.get("ccode").toString());
			}else if("dep".equals(monitorType)){
				q.setDepCode(depGroup.get("ccode").toString());
			}else{
				continue;
			}
			q.setPlanYear(planYear);
			q.setRoleName(DrgsIndex.getRoleCode());
			List<QuotaAdjust> list = quotaAdjustApplication.findQuotaAdjustBy(q);
			if(list.size()>0){
				for (QuotaAdjust quotaAdjust : list) {
					if ("AvgDays".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgDaysL", quotaAdjust.getLowValue());
						map.put("AvgDaysH", quotaAdjust.getHighValue());
					}
					if ("AvgFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgFeeL", quotaAdjust.getLowValue());
						map.put("AvgFeeH", quotaAdjust.getHighValue());
					}
					if ("HCAvgFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("HCAvgFeeL", quotaAdjust.getLowValue());
						map.put("HCAvgFeeH", quotaAdjust.getHighValue());
					}
					if ("AvgDrugFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgDrugFeeL", quotaAdjust.getLowValue());
						map.put("AvgDrugFeeH", quotaAdjust.getHighValue());
					}
					if ("HCAvgDrugFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("HCAvgDrugFeeL", quotaAdjust.getLowValue());
						map.put("HCAvgDrugFeeH", quotaAdjust.getHighValue());
					}
					//加入次均药耗费
					if ("AvgDrugMateFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgDrugMateFeeL", quotaAdjust.getLowValue());
						map.put("AvgDrugMateFeeH", quotaAdjust.getHighValue());
					}
					if ("HCAvgDrugMateFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("HCAvgDrugMateFeeL", quotaAdjust.getLowValue());
						map.put("HCAvgDrugMateFeeH", quotaAdjust.getHighValue());
					}
				}
			}else{
				map.put("AvgDaysL", 0);
				map.put("AvgDaysH", 0);
				map.put("AvgFeeL", 0);
				map.put("AvgFeeH", 0);
				map.put("HCAvgFeeL", 0);
				map.put("HCAvgFeeH", 0);
				map.put("AvgDrugFeeL", 0);
				map.put("AvgDrugFeeH", 0);
				map.put("HCAvgDrugFeeL", 0);
				map.put("HCAvgDrugFeeH", 0);
				map.put("AvgDrugMateFeeL", 0);
				map.put("AvgDrugMateFeeH", 0);
				map.put("HCAvgDrugMateFeeL", 0);
				map.put("HCAvgDrugMateFeeH", 0);
			}
			
			resultList.add(map);
		}
		return resultList;
	}

	/**
	 * @methodname :loadDepParam
	 * @description : 获取科室调整参数
	 * @param :
	 * @author :lileizheng
	 * @return :
	 * @date :2015年7月13日
	 */
	public List<Map<String, Object>> loadDepParam(String pardepgroupCode,String dateFrom,String dateTo,String forecastYear) {
		List<Map<String, Object>> resultList = new LinkedList<>();
		IndexCalDTO dto=new IndexCalDTO();
		dto.setDateFrom(dateFrom);
		dto.setDateTo(dateTo);
		dto.setMonitorType("dep");
		dto.setPardepgroupCode(pardepgroupCode);
		dto.setQuotaCode("TotalCaseCnt");
		dto.setgType("0");
		List<Map<String, Object>> depList = drgsIndexCalFacade.indexCal(dto);
		for (Map<String, Object> dep : depList) {
			Map<String, Object> map = new HashMap<>();
			map.put("depCode", dep.get("ccode"));
			map.put("depDesc", dep.get("ddesc"));
			map.put("TotalCaseCnt", dep.get("QuotaValue"));
			QuotaAdjust q = new QuotaAdjust();
			q.setDepCode(dep.get("ccode").toString());
			q.setPlanYear(forecastYear);
			q.setRoleName(DrgsIndex.getRoleCode());
			List<QuotaAdjust> list = quotaAdjustApplication.findQuotaAdjustBy(q);
				for (QuotaAdjust quotaAdjust : list) {
					if ("AvgDays".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgDaysL", quotaAdjust.getLowValue());
						map.put("AvgDaysH", quotaAdjust.getHighValue());
					}
					if ("AvgFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgFeeL", quotaAdjust.getLowValue());
						map.put("AvgFeeH", quotaAdjust.getHighValue());
					}
					if ("HCAvgFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("HCAvgFeeL", quotaAdjust.getLowValue());
						map.put("HCAvgFeeH", quotaAdjust.getHighValue());
					}
					if ("AvgDrugFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgDrugFeeL", quotaAdjust.getLowValue());
						map.put("AvgDrugFeeH", quotaAdjust.getHighValue());
					}
					if ("HCAvgDrugFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("HCAvgDrugFeeL", quotaAdjust.getLowValue());
						map.put("HCAvgDrugFeeH", quotaAdjust.getHighValue());
					}
					//加入次均药耗费
					if ("AvgDrugMateFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("AvgDrugMateFeeL", quotaAdjust.getLowValue());
						map.put("AvgDrugMateFeeH", quotaAdjust.getHighValue());
					}
					if ("HCAvgDrugMateFee".equals(quotaAdjust.getQuotaCode())) {
						map.put("HCAvgDrugMateFeeL", quotaAdjust.getLowValue());
						map.put("HCAvgDrugMateFeeH", quotaAdjust.getHighValue());
					}
				}
			resultList.add(map);
		}
		return resultList;
	}

	/**
	 * @methodname :getDepDisParam
	 * @description :
	 * @param :
	 * @author :lileizheng
	 * @return :
	 * @date :2015年7月13日
	 */
	public InvokeResult loadDepDisParam(IndexCalDTO dto) {
//		String mrLotLY = dto.getMrLot();
//		dto.setMrLot(mrLotLY);
//		dto.setMrType("MC");
//		dto.setMrStdtype("year");
//		String stdYear = mrLotLY.substring(0, 4);
//		List<Map<String, Object>> resultList = new LinkedList<Map<String, Object>>();
//		// 获取科室重点病种
//		List<MonitorResult> list = drgsApplication.findDrgsByDep(MonitorResultAssembler.toEntity(dto), dto.getType1());
//		for (MonitorResult monitorResult : list) {
//			Map<String, Object> map = new HashMap<>();
//			map.put("drgCode", monitorResult.getPardrgCode());
//			DRGs drg = drgsApplication.getDRGs(monitorResult.getPardrgCode(), "V2015");
//			map.put("drgDesc", drg.getDrgDesc());
//			List<QuotaDtl> quotaList = monitorResult.getQuotaList();
//			for (QuotaDtl quotaDtl : quotaList) {
//				if ("AvgDays".equals(quotaDtl.getParquotaCode())) {
//					map.put("AvgDaysValue", quotaDtl.getQuotaDetail());
//				}
//				if ("AvgFee".equals(quotaDtl.getParquotaCode())) {
//					map.put("AvgFeeValue", quotaDtl.getQuotaDetail());
//				}
//				if ("HCAvgFee".equals(quotaDtl.getParquotaCode())) {
//					map.put("HCAvgFeeValue", quotaDtl.getQuotaDetail());
//				}
//				if ("DrugFee".equals(quotaDtl.getParquotaCode())) {
//					map.put("DrugFeeValue", quotaDtl.getQuotaDetail());
//				}
//				if ("HCDrugFee".equals(quotaDtl.getParquotaCode())) {
//					map.put("HCDrugFeeValue", quotaDtl.getQuotaDetail());
//				}
//				if ("TotalCaseCnt".equals(quotaDtl.getParquotaCode())) {
//					map.put("TotalCaseCnt", quotaDtl.getQuotaDetail());
//				}
//			}
//
//			QuotaManage quotaManage = new QuotaManage();
//			quotaManage.setPardrgCode(monitorResult.getPardrgCode());
//			quotaManage.setManageYear(stdYear);
//			List<QuotaManage> quotaManageList = quotaManageApplication.getQuotaMange(quotaManage);
//			for (QuotaManage m : quotaManageList) {
//				if ("AvgDays".equals(m.getParquotaCode())) {
//					map.put("AvgDaysBenchmark", m.getManageBenchmark());
//				}
//				if ("AvgFee".equals(m.getParquotaCode())) {
//					map.put("AvgFeeBenchmark", m.getManageBenchmark());
//					map.put("HCAvgFeeBenchmark", m.getManageBenchmark());
//				}
//				if ("DrugFee".equals(m.getParquotaCode())) {
//					map.put("DrugFeeBenchmark", m.getManageBenchmark());
//					map.put("HCDrugFeeBenchmark", m.getManageBenchmark());
//				}
//			}
//
//			// 获取数据库保存的参数
//			QuotaAdjust q = new QuotaAdjust();
//			q.setDepCode(dto.getPardepCode());
//			q.setParDepGroupCode(dto.getPardepgroupCode());
//			q.setDrgCode(monitorResult.getPardrgCode());
//			q.setPlanYear(year);
//			List<QuotaAdjust> quotaList1 = quotaAdjustApplication.findQuotaAdjustBy(q);
//			for (QuotaAdjust quotaAdjust : quotaList1) {
//				if ("AvgDays".equals(quotaAdjust.getQuotaCode())) {
//					map.put("AvgDaysL", quotaAdjust.getLowValue());
//					map.put("AvgDaysH", quotaAdjust.getHighValue());
//				}
//				if ("AvgFee".equals(quotaAdjust.getQuotaCode())) {
//					map.put("AvgFeeL", quotaAdjust.getLowValue());
//					map.put("AvgFeeH", quotaAdjust.getHighValue());
//				}
//				if ("HCAvgFee".equals(quotaAdjust.getQuotaCode())) {
//					map.put("HCAvgFeeL", quotaAdjust.getLowValue());
//					map.put("HCAvgFeeH", quotaAdjust.getHighValue());
//				}
//				if ("DrugFee".equals(quotaAdjust.getQuotaCode())) {
//					map.put("DrugFeeL", quotaAdjust.getLowValue());
//					map.put("DrugFeeH", quotaAdjust.getHighValue());
//				}
//				if ("HCDrugFee".equals(quotaAdjust.getQuotaCode())) {
//					map.put("HCDrugFeeL", quotaAdjust.getLowValue());
//					map.put("HCDrugFeeH", quotaAdjust.getHighValue());
//				}
//			}
//
//			resultList.add(map);
//		}
		return InvokeResult.success();
	}
/**
 *  @Description：保存科室调整参数
 *  @Author：liuhongjun 
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#saveParamDepData(com.dhcc.DRGsHosp.facade.dto.IndexCalDTO)
 */
	@Override
	public InvokeResult saveParamDepData(String adjustParameter,String dateFrom,String dateTo,String forecastYear) {
		String planYear=forecastYear;
		String[] depList = adjustParameter.split(",");
		for (String depParam : depList) {
			QuotaAdjust quotaAdjust = new QuotaAdjust();
			quotaAdjust.setPlanYear(planYear);
			String[] param = depParam.split("\\|");
			String depCode = param[0];
			quotaAdjust.setDepCode(depCode);
			for (String quotas : param[1].split("-")) {
				String[] quotaValue = quotas.split(":");
					quotaAdjust.setDepCode(depCode);
					quotaAdjust.setQuotaCode(quotaValue[0]);
					quotaAdjust.setHighValue(quotaValue[2] != null ? Double.parseDouble(quotaValue[2]) : 0);
					quotaAdjust.setLowValue(quotaValue[1] != null ? Double.parseDouble(quotaValue[1]) : 0);
					String id=depCode + "_" + planYear + "_" + quotaValue[0]+"_"+DrgsIndex.getRoleCode();			
					quotaAdjust.setId(id);
					quotaAdjust.setRoleName(DrgsIndex.getRoleCode());
					quotaAdjustApplication.creatQuotaAdjust(quotaAdjust);
			}
		}
		return InvokeResult.success();
	}

	@Override
	public InvokeResult saveParamDepDisData(IndexCalDTO dto) {
		String paramstr = dto.getType1();
		String depCode = dto.getPardepCode();
		String[] depList = paramstr.split(",");
		for (String depParam : depList) {
			QuotaAdjust quotaAdjust = new QuotaAdjust();
			quotaAdjust.setPlanYear(year);
			String[] param = depParam.split("\\|");
			String drgCode = param[0];
			quotaAdjust.setDrgCode(drgCode);
			quotaAdjust.setDepCode(depCode);
			for (String quotas : param[1].split("-")) {
				String[] quotaValue = quotas.split(":");
				quotaAdjust.setQuotaCode(quotaValue[0]);
				quotaAdjust.setHighValue(quotaValue[2] != null ? Double.parseDouble(quotaValue[2]) : 0);
				quotaAdjust.setLowValue(quotaValue[1] != null ? Double.parseDouble(quotaValue[1]) : 0);
				String id = depCode + "_" + drgCode + "_" + year + "_" + quotaValue[0];
				quotaAdjust.setId(id);
				quotaAdjustApplication.updateQuotaAdjust(quotaAdjust);
			}
		}
		return InvokeResult.success();
	}

	@Override
	public InvokeResult saveParamDepGroupDisData(IndexCalDTO dto) {
		String paramstr = dto.getType1();
		String depGoupCode = dto.getPardepgroupCode();
		String[] depList = paramstr.split(",");
		for (String depParam : depList) {
			QuotaAdjust quotaAdjust = new QuotaAdjust();
			quotaAdjust.setPlanYear(year);
			String[] param = depParam.split("\\|");
			String drgCode = param[0];
			quotaAdjust.setDrgCode(drgCode);
			quotaAdjust.setParDepGroupCode(depGoupCode);
			for (String quotas : param[1].split("-")) {
				String[] quotaValue = quotas.split(":");
				quotaAdjust.setQuotaCode(quotaValue[0]);
				quotaAdjust.setHighValue(quotaValue[2] != null ? Double.parseDouble(quotaValue[2]) : 0);
				quotaAdjust.setLowValue(quotaValue[1] != null ? Double.parseDouble(quotaValue[1]) : 0);
				String id = depGoupCode + "_" + drgCode + "_" + year + "_" + quotaValue[0];
				quotaAdjust.setId(id);
				quotaAdjustApplication.updateQuotaAdjust(quotaAdjust);
			}
		}
		return InvokeResult.success();
	}
	
	/**
	 *  @desp  ：获取全院，科室组，科室的原始值
	 *  @Author： liuhongjun
	 *  @param dto
	 *  @return
	 *  @Date  :2018年3月13日下午8:41:23
	 */
	public Map<String, Object> getHospDatabyDepCode(IndexCalDTO dto) {
		Map<String, Object> mResult = new HashMap<>();
		dto.setQuotaCode("AvgDays,AvgFee,AvgDrugFee,TotalCaseCnt,HCCaseCnt,HCTotalCaseCnt,HCAvgDrugFee,HCAvgDays,HCAvgFee,HCTotalFund,TotalDays,AvgDrugMateFee,HCAvgDrugMateFee,TimeEff,FeeEff");
		dto.setMonitorType("hosp");
		dto.setIsGetCc("0");
		List<Map<String, Object>> resultList = drgsIndexCalFacade.indexCal(dto);
		if(resultList.size()>0){
			mResult = resultList.get(0);
		}
		return mResult;
	}
/**
 *  @Description：获取科室全院的测算指标
 *  @Author LiuHongJun  
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#getHospData(com.dhcc.DRGsHosp.facade.dto.IndexCalDTO)
 */
	@Override
	public InvokeResult getHospData(IndexCalDTO dto) {
		Map<String, Object> mResult = new HashMap<>();
		dto.setQuotaCode("ForeCast");
		dto.setMonitorType("hosp");
		dto.setgType("1");
		List<Map<String, Object>> resultList = drgsIndexCalFacade.indexCal(dto);
		if(resultList.size()>0){
			mResult = resultList.get(0);
		}
		return InvokeResult.success(mResult);
	}

	@Override
	public InvokeResult getNewPlan(String depCode, String addYear) {
		List<Object[]> list = foreCastApplication.getNewPlan(depCode, addYear);
		List<Map<String, Object>> resultList = new LinkedList<>();
		for(Object[] objs: list){
			Map<String, Object> map = new HashMap<>();
			map.put("depCode", objs[0]);
			map.put("depName", objs[1]);
			map.put("beds", objs[2]);
			map.put("addYear", objs[3]);
			map.put("bedDays", objs[4]);
			map.put("hcratio", objs[5]);
			map.put("hcfundratio", objs[6]);
			map.put("isNew", objs[7]);
			resultList.add(map);
		}
		return InvokeResult.success(resultList);
	}

	@Override
	public InvokeResult savePlan(Map<String, Object> json) {
		try{
			foreCastApplication.savePlan(json);
		}catch(Exception e){
			return InvokeResult.failure(e.getMessage());
		}
		return InvokeResult.success();
	}

	@Override
	public InvokeResult delPlan(String depCode, String addYear) {
		try{
			foreCastApplication.delPlan(depCode, addYear);
		}catch(Exception e){
			return InvokeResult.failure(e.getMessage());
		}
		return InvokeResult.success();
	}

	@Override
	public InvokeResult getNewPlanDRGs(String depCode, String addYear) {
		List<Object[]> list = foreCastApplication.getNewPlanDRGs(depCode, addYear);
		List<Map<String, Object>> resultList = new LinkedList<>();
		for(Object[] objs: list){
			Map<String, Object> map = new HashMap<>();
			map.put("drgCode", objs[0]);
			map.put("totalCaseCnt", objs[1]);
			map.put("avgDays", objs[2]);
			map.put("avgFee", objs[3]);
			map.put("avgDrugFee", objs[4]);
			resultList.add(map);
		}
		return InvokeResult.success(resultList);
	}

	@Override
	public InvokeResult saveNewPlanDRGs(List<Map<String, Object>> json, String depCode, String addYear) {
		try{
			foreCastApplication.saveNewPlanDRGs(json, depCode, addYear);
		}catch(Exception e){
			return InvokeResult.failure(e.getMessage());
		}
		return InvokeResult.success();
	}

	@Override
	public InvokeResult changeYear(String year) {
		ForeCastFacadeImpl.year = year;
		return InvokeResult.success();
	}
/**
 * 
 *  @Description：保存绩效
 *  @Author LiuHongJun  
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#saveToQuotamanage()
 */
	@Override
	public InvokeResult saveToQuotamanage(String stdType,String saveType,String planYear,String roleCode) {
		try{
			foreCastApplication.saveToQuotamanage(stdType,saveType,planYear,roleCode);
		}catch(Exception e){
			return InvokeResult.failure(e.toString());
		}
		return InvokeResult.success();
	}
/**
 *  @throws ParseException 
 * @Description：保存测算的医保数据
 *  @Author LiuHongJun  
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#saveExpected(java.lang.String, java.lang.String, java.lang.String)
 */
@Override
public InvokeResult saveExpected(String quotaStr, String saveType, String type,String planYear,String dateFrom,String dateTo) throws ParseException {
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			dateFrom = DrgsIndex.formateDateFrom(dateFrom);
			dateTo = DrgsIndex.formateDateTo(dateTo);
			String year = planYear;
			String[] expected = quotaStr.split("\\|");
			String ccode = expected[0];
			String id = "";
			if ("hosp".equals(ccode)) {
				id = "hosp_" + year + "_" + saveType;
			} else {
				id = ccode + "_" + year + "_" + saveType;
			}
			String expectQuota = expected[1];
			String[] expectQuotas = expectQuota.split(",");
			for (String quota : expectQuotas) {
				String[] quotas = quota.split(":");
				if (quotas.length > 1) {
					String quotaCode = quotas[0];
					String quotaValue = quotas[1];
					if ("医保".equals(CurrentUser.getRoleName())) {
						QuotaExpected qe = new QuotaExpected();
						String quoId = id + "_" + quotaCode + "_" + DrgsIndex.getRoleCode();
						qe.setExpectedId(quoId);
						qe.setExpectedCode(saveType);
						qe.setExpectedYear(year);
						qe.setObjType(type);
						qe.setParQuotaCode(quotaCode);
						qe.setReume(null);
						qe.setExpectedValue(quotaValue != null ? Double.parseDouble(quotaValue) : 0);
						qe.setMrDateFrom(sdf.parse(dateFrom));
						qe.setMrDateTo(sdf.parse(dateTo));
						qe.setRoleName(DrgsIndex.getRoleCode());
						quotaExpectApplication.creatQuotaExpected(qe);
					} else {
						if (quotaCode.indexOf("HC") == -1) {
							QuotaExpected qe = new QuotaExpected();
							String quoId = id + "_" + quotaCode + "_" + DrgsIndex.getRoleCode();
							qe.setExpectedId(quoId);
							qe.setExpectedCode(saveType);
							qe.setExpectedYear(year);
							qe.setObjType(type);
							qe.setParQuotaCode(quotaCode);
							qe.setReume(null);
							qe.setExpectedValue(quotaValue != null ? Double.parseDouble(quotaValue) : 0);
							qe.setMrDateFrom(sdf.parse(dateFrom));
							qe.setMrDateTo(sdf.parse(dateTo));
							qe.setRoleName(DrgsIndex.getRoleCode());
							quotaExpectApplication.creatQuotaExpected(qe);
						}				
					}
				}
			}
			return InvokeResult.success();
		}catch(Exception e) {
		return InvokeResult.failure(e.getMessage());
	}
}
/**
 * 
 *  @Description：获取上次全院数据
 *  @Author LiuHongJun  
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#getLastResultHosp(java.lang.String)
 */
@Override
public InvokeResult getLastResultHosp(String saveType,String year,String roleName,String dateFrom,String dateTo) {
	 dateFrom=DrgsIndex.formateDateFrom(dateFrom);
	 dateTo= DrgsIndex.formateDateTo(dateTo);
	Map<String, Object> resultMap = new HashMap<>();
	List<QuotaExpected> dtlList = quotaExpectApplication.getQuotaExpectedByCode(saveType,"hosp",year,roleName, dateFrom, dateTo);
	if(!dtlList.isEmpty()) {
		for(QuotaExpected quotaExpected: dtlList){
			resultMap.put(quotaExpected.getParQuotaCode(), quotaExpected.getExpectedValue());
		}
	}
return InvokeResult.success(resultMap);
}
/**
 * 
 *  @Description：获取上次科室组数据
 *  @Author LiuHongJun  
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#getLastResultDepGroup(java.lang.String)
 */
@Override
public InvokeResult getLastResultDepGroup(String saveType,String year,String roleName,String dateFrom,String dateTo) {
	 dateFrom=DrgsIndex.formateDateFrom(dateFrom);
	 dateTo= DrgsIndex.formateDateTo(dateTo);
	List<Map<String, Object>> resultList = new LinkedList<>();
	List<String > list = quotaExpectApplication.getCode(saveType,"depGroup",year,roleName);
	if(!list.isEmpty()) {
		for(String code :list) {
			Map<String, Object> resultMap = new HashMap<>();
			resultMap.put("depGroupCode", code);
			DepGroup depGroup = depGroupApplication.getDepGroup(code);
			resultMap.put("depGroupDesc", depGroup.getDepGroupDesc());
			List<Map<String, Object>> dtlList = quotaExpectApplication.getQuotaExpectedMapByCode(saveType,"depGroup",year,code,roleName, dateFrom, dateTo);
			if(!dtlList.isEmpty()) {
				for(Map<String, Object> map:dtlList) {
					String quotaCode=map.get("QUOTA_CODE")==null?"":map.get("QUOTA_CODE").toString();
					String quotaValue=map.get("QUOTA_VALUE")==null?"":map.get("QUOTA_VALUE").toString();
					if("AvgDays".equals(quotaCode)){
						resultMap.put("AvgDays", quotaValue);
					}
					if("AvgFee".equals(quotaCode)){
						resultMap.put("AvgFee", quotaValue);
					}
					if("HCAvgFee".equals(quotaCode)){
						resultMap.put("HCAvgFee", quotaValue);
					}
					if("AvgDrugFee".equals(quotaCode)){
						resultMap.put("AvgDrugFee", quotaValue);
					}
					if("HCAvgDrugFee".equals(quotaCode)){
						resultMap.put("HCAvgDrugFee", quotaValue);
					}
					if("TotalCaseCnt".equals(quotaCode)){
						resultMap.put("TotalCaseCnt", quotaValue);
					}
					if("HCCaseCnt".equals(quotaCode)){
						resultMap.put("HCCaseCnt", quotaValue);
					}
					if("HCTotalFund".equals(quotaCode)){
						resultMap.put("HCTotalFund", quotaValue);
					}
					if("TimeEff".equals(quotaCode)){
						resultMap.put("TimeEff", quotaValue);
					}
					if("FeeEff".equals(quotaCode)){
						resultMap.put("FeeEff", quotaValue);
					}
					if("AvgDrugMateFee".equals(quotaCode)){
						resultMap.put("AvgDrugMateFee", quotaValue);
					}
					if("HCAvgDrugMateFee".equals(quotaCode)){
						resultMap.put("HCAvgDrugMateFee", quotaValue);
					}
					if("CMI".equals(quotaCode)){
						resultMap.put("CMI", quotaValue);
					}
				}
			}
			resultList.add(resultMap);
		}
	}
	return InvokeResult.success(resultList);
}
/**
 * 
 *  @Description：获取上次科室数据
 *  @Author LiuHongJun  
 *  @see com.dhcc.DRGsHosp.facade.ForeCastFacade#getLastResultDep(java.lang.String)
 */
@Override
public InvokeResult getLastResultDep(String saveType,String year,String roleName,String dateFrom,String dateTo) {
	 dateFrom=DrgsIndex.formateDateFrom(dateFrom);
	 dateTo= DrgsIndex.formateDateTo(dateTo);
	List<Map<String, Object>> resultList = new LinkedList<>();
	List<String > list = quotaExpectApplication.getCode(saveType,"dep",year,roleName);
	if(!list.isEmpty()) {
		for(String code :list) {
			Map<String, Object> resultMap = new HashMap<>();
			resultMap.put("depCode", code);
			Department dep = departmentApplication.getDepartment(code);
			if(dep!=null) {
				resultMap.put("depDesc", dep.getDepName());
			}
			List<Map<String, Object>> dtlList = quotaExpectApplication.getQuotaExpectedMapByCode(saveType,"dep",year,code,roleName, dateFrom, dateTo);
			if(!dtlList.isEmpty()) {
				for(Map<String, Object> map:dtlList) {
					String quotaCode=map.get("QUOTA_CODE")==null?"":map.get("QUOTA_CODE").toString();
					String quotaValue=map.get("QUOTA_VALUE")==null?"":map.get("QUOTA_VALUE").toString();
					if("AvgDays".equals(quotaCode)){
						resultMap.put("AvgDays", quotaValue);
					}
					if("AvgFee".equals(quotaCode)){
						resultMap.put("AvgFee", quotaValue);
					}
					if("HCAvgFee".equals(quotaCode)){
						resultMap.put("HCAvgFee", quotaValue);
					}
					if("AvgDrugFee".equals(quotaCode)){
						resultMap.put("AvgDrugFee", quotaValue);
					}
					if("HCAvgDrugFee".equals(quotaCode)){
						resultMap.put("HCAvgDrugFee", quotaValue);
					}
					if("TotalCaseCnt".equals(quotaCode)){
						resultMap.put("TotalCaseCnt", quotaValue);
					}
					if("HCCaseCnt".equals(quotaCode)){
						resultMap.put("HCCaseCnt", quotaValue);
					}
					if("HCTotalFund".equals(quotaCode)){
						resultMap.put("HCTotalFund", quotaValue);
					}
					if("TimeEff".equals(quotaCode)){
						resultMap.put("TimeEff", quotaValue);
					}
					if("FeeEff".equals(quotaCode)){
						resultMap.put("FeeEff", quotaValue);
					}
					if("AvgDrugMateFee".equals(quotaCode)){
						resultMap.put("AvgDrugMateFee", quotaValue);
					}
					if("HCAvgDrugMateFee".equals(quotaCode)){
						resultMap.put("HCAvgDrugMateFee", quotaValue);
					}
					if("CMI".equals(quotaCode)){
						resultMap.put("CMI", quotaValue);
					}
				}
			}
			resultList.add(resultMap);
		}
	}
	return InvokeResult.success(resultList);
}
}
